<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            align-items: center;
        }

        .content .btn {
            height: 50px;
            width: 170px;
        }

        .content .btn button {
            height: 100%;
            width: 100%;
            border: none;
            outline: none;
            background: #d33f8d;
            color: #fff;
            border-radius: 5px;
            font-size: 18px;
            letter-spacing: 1px;
            font-weight: 500;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn button:hover {
            background: #000;
        }

        .content .file-name {
            position: relative;
            background: #d33f8d;
            color: #fff;
            padding: 8px 12px;
            border-radius: 5px;
            margin-left: 15px;
            user-select: none;
            display: none;
        }

        .content .file-name::before {
            position: absolute;
            content: '';
            height: 15px;
            width: 15px;
            background: #d33f8d;
            left: -7px;
            top: 50%;
            z-index: -1;
            transform: translateY(-50%) rotate(45deg);
        }
    </style>
</head>

<body>
    <div class="content">
        <input id="default-btn" type="file" hidden>
        <div class="btn">
            <button onclick="active()" id="custom-btn">Choose a file</button>
        </div>
        <div class="file-name">No file chosen</div>
    </div>
</body>
<!-- 显示文件名字和类型（英文） -->
<script>
    const defaultBtn = document.querySelector("#default-btn");
    const customBtn = document.querySelector("#custom-btn");
    const fileName = document.querySelector(".file-name");
    let regExp = /[0-9a-zA-Z\^\&\'\@\{\}\[\]\,\$\=\!\-\#\(\)\.\%\+\~\_]+$/;
    function active() {
        defaultBtn.click();
    }
    defaultBtn.addEventListener("change", function () {
        if (this.value) {
            let nameValue = this.value.match(regExp);
            fileName.style.display = "block";
            fileName.textContent = nameValue;
        } else {
            fileName.style.display = "block";
            fileName.textContent = "NO file chosen";
        }
    });
</script>

</html>